<?php
include "includes/sesiones.php";
include "includes/comunes.php";
require_once("includes/paginator.class.php");
$pages = new Paginator;
//error_reporting(E_ALL);




$where=" where 1=1";
if(isset($_GET['Enviar'])){


  if(isset($_GET['dni']) and $_GET['dni']<>"")
      $where.=" and GestionCliente=".trim($_GET['dni'])." ";
   if(isset($_GET['cre']) and $_GET['cre']<>"")
      $where.=" and GestionCredito=".trim($_GET['cre'])." ";
   if(isset($_GET['fechaD']) and $_GET['fechaD']<>"")
      $where.=" and GestionFecha >='".trim($_GET['fechaD'])."'";
	  if(isset($_GET['fechaH']) and $_GET['fechaH']<>"")
      $where.=" and GestionFecha <='".trim($_GET['fechaH'])."'";
  if(isset($_GET['tipo']) and $_GET['tipo']<>0)
      $where.=" and GestionTipo='".trim($_GET['tipo'])."'";
  if(isset($_GET['ope']) and $_GET['ope']<>0)
      $where.=" and GestionOperador=".trim($_GET['ope'])." ";
  

	

   $sql="select * from cob_gestiones ".$where." order by GestionId desc ";

 
   $rescli=  cons_ins($sql);

}
else{

	$sql="select  * from cob_gestiones order by GestionId desc ";
	

$rescli= cons_ins($sql);



}
//echo $sql;
$pages->items_total = mysql_num_rows($rescli);
$pages->mid_range = 9;
$pages->paginate();
$rescli= cons_ins($sql.$pages->limit);
//echo  $sql.$pages->limit;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<!--
  fin estilo scroll-->
<?php include "includes/metas.php";?>
<!--libreria jquery central-->
<script src="jquery-ui/js/jquery-1.9.1.js"></script>
<!--fin libreria central-->
<!--librerias ui-->
<link href="jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<!--fin libreria-->
<!--libreria flexigrid-->
<link rel="stylesheet" type="text/css" href="jquery-ui/css/ui-flexigrid/flexigrid.css">
<script type="text/javascript" src="jquery-ui/js/flexigrid.js"></script>
<!--fin libreria-->
<link href="modal/styles/modal-window.css" type="text/css" rel="stylesheet" />
<script language="JavaScript" type="text/javascript">
$(function()
{
$('#flex1').flexigrid({
      colModel : [
                
		{display: 'Nro.', name : 'pedidoID', width : 40, sortable : true, align: 'center'},
		{display: 'Fecha', name : 'fecha', width : 53, sortable : true, align: 'left'},
		{display: 'Tipo Gestion', name : 'nombre', width : 110, sortable : true, align: 'left'},
		{display: 'Credito', name : 'entidad', width : 40, sortable : true, align: 'left'},
		{display: 'Cliente', name : 'mtootor', width : 150, sortable : true, align: 'left'},
        {display: 'Operador', name : 'deuda', width : 60, sortable : true, align: 'left'},
        
		],
                width: 490,
                height: 1100
              
  });
  
  $('#tratar').tooltip({
      track: true
    });
	
	 $( "#fechaD" ).datepicker({
         dateFormat: "yy-mm-dd"

      });
	  
	   $( "#fechaH" ).datepicker({
         dateFormat: "yy-mm-dd"

      });

});
</script>


</head>

<body>
<div class="contenedor">
	<div class="cont">
    	<?php include "includes/head.php";?>
        <?php include "includes/menu.php";?>
        

    	<div class="novedadescont">
<!--            <div class="novedadestitulo">
            	<div class="menuvolver"> <a href="javascript:history.back(1)">Volver Atrás</a></div>
            </div>-->
            <div class="novedadestitulo">
            <div class="novetitulo2">Listado de Gestiones</div>
            </div>
           
                <?php
                  if($_GET['credito'])
                      echo '<div class="mensaje">Se ha creado exitosamente el credito Nº <strong>'.$_GET['credito'].'</strong> &nbsp;&nbsp;&nbsp;<a href="ImprimirCredito.php?cre_id='.$_GET['credito'].'" target="_new"><img src="images/imprimir.png" border="0" width="25px" alt="Imprimir"/></a></div>'
                ?>


            
            <div class="formucont">
                 <form id="form1" name="form1" method="get" action="ListadoGestiones.php">
           	 

              <div class="formlinea">
                <div class="formtxt">Dni</div>
                <div class="formtxt2">
                    <input name="dni" type="text" id="form" size="25" />
                </div>
                </div>


                     <div class="formlinea">
                <div class="formtxt">Nº Credito</div>
                <div class="formtxt2">
                    <input name="cre" type="text" id="form" size="25" />
                </div>
                </div>

                      <div class="formlinea">
                <div class="formtxt">Fecha Desde</div>
                <div class="formtxt2">
                    <input name="fechaD" type="text" id="fechaD" size="25" />
                </div>
                </div>
				
				 <div class="formlinea">
                <div class="formtxt">Fecha Hasta</div>
                <div class="formtxt2">
                    <input name="fechaH" type="text" id="fechaH" size="25" />
                </div>
                </div>
				
                <div class="formlinea">
                <div class="formtxt">Tipo de Gestion</div>
                <div class="formtxt2">
                   <?php echo listar_tipo_gestion();?>
                </div>
                </div>

                   
                       <div class="formlinea">
                <div class="formtxt">Operador</div>
                <div class="formtxt2">
                     <?php echo listar_operadores();?>
                </div>
                </div>
                 <div class="formlinea">
                <div class="formtxt"></div>
                <div class="formtxt2">
                    
                </div>
                </div>      


                 <div class="botcont">
                <input name="Enviar" class="bot" type="submit" value="Buscar" />
                </div>
                </form>
            </div> 


        	<div class="novedadestitulo">
            	<div class="novetitulo2">Resultado<br>
                </div>
            </div>
            
            <div style="align:left;"> <a href="valclientes.php"><img src="images/nuevo.png" border="0" width="40px" title="Nuevo Credito"/></a></div>
            <div class="listadocont">
            	<div class="listadocol2">
                    
				 <table id="flex1"style="display:none;width: 80%">

               <tbody>	
					
					
<?php
if ($pages->items_total>0):
 while ($regcli=mysql_fetch_array($rescli)):?>
  <tr >
    <td><?php echo $regcli['GestionId']?></td>
    <td><?php echo format_fec($regcli['GestionFecha'],"/")?></td>
    <td>&nbsp;<?php echo tipo_gestion($regcli['GestionTipo'])?>&nbsp;</td>
    <td><?php echo $regcli['GestionCredito'] ?></td>
    <td> <?php echo obtener_cliente($regcli['GestionCliente'])?></td>
    <td> <?php echo operadores($regcli['GestionOperador'])?></td>
	 <td>
<!--     <a href="editarclientes.php?cre_id=<?php //echo $rescli->fields['id']?>"><img src="images/editar.png" border="0" width="25px" alt="Editar" title="Editar"/></a>-->
     <a href="verGestion.php?cre_id=<?php echo $regcli['GestionCredito']?>&nro=<?php echo $regcli['GestionId']?>" onclick="$(this).modal({width:903, height:600}).open(); return false;"><img src="images/visualizar.png" border="0" width="25px" alt="Visualizar" title="Visualizar"/></a>
   <!--     <a href="EliminarCreditos.php?cre_id=<?php //echo $rescli->fields['id']?>"><img src="images/eliminar.jpg" border="0" width="25px" alt="Eliminar" title="Eliminar"/></a>-->

<!--    <a href="#"><img src="images/ref.png" border="0" width="80px"/></a>-->
    </td>
  </tr>
 <?php
 endwhile ;
 endif;
 ?>
 <tr>
                       <td colspan="8"><?php echo $pages->display_jump_menu();echo $pages->display_items_per_page();echo $pages->display_pages() ?></td>
                   </tr>
 </tbody>

</table>
                	
<!--                    <a href="#" class="listadolinea">Texto o nombre del listado.</a>                    -->
                </div>
<!--                <div class="listadocol">
                	<a href="#"><img src="images/ed.png" border="0" /></a>
                   <a href="#"><img src="images/vis.png" border="0" /></a>
					<a href="#"><img src="images/imp.png" border="0" /></a>
                	<a href="#"><img src="images/ref.png" border="0" /></a>
                    
                    
                </div>-->

                               </div>
            
            
            
            
        	<div class="novedadesbottom"></div>
        </div>
    
    
    
    
    <div class="separador"></div>
 <?php include "includes/menufooter.php";?>
    
    
	<div id="clearing"></div>    
    </div>
<div id="clearing"></div>
</div>
<script type="text/javascript" language="javascript" src="modal/scripts/modal-window.min.js"></script>  
</body>
</html>
